home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / amigae.sept.archive / 000074_George_Beasley:.msg < prev    next >
Text File  |  1993-11-02  |  2KB  |  61 lines

  1. ----------------------------------------------------------------------------
  2.  
  3.         PROBEMS WITH THE TRIG FUNCTIONS IN MATHTRANS.LIBRARY
  4.  
  5. I have a problem.  I need, given an angle and the distance to move at that
  6. angle, to know the delta_x and delta_y so that I can move an object to the
  7. new location.  To do this I am using the MathFFP and MathTrans libraries.
  8.  
  9. If my old math notes are correct, the way to do this is with the following
  10. two equations:
  11.  
  12.             delta_x = cos( angle in radians ) * radius
  13.             delta_y = sin( angle in radians ) * radius
  14.  
  15. My first problem is that my angle is in degrees, so I need to convert it to
  16. radians.  To do this (again with the help of my old math notes), I believe
  17. the eauation is:
  18.  
  19.                             pi
  20.                 radians = ------ * degrees
  21.                            180
  22.  
  23. Converting this all to E, I get:
  24.  
  25.     PROC newXY( degrees, radius )
  26.  
  27.       DEF delta_x,
  28.           delta_y
  29.  
  30.       delta_x = SpFix( SpMul( SpCos( SpMul( SpDiv( 3.14159265, 180.0 ),
  31.                               SpFlt( degrees ))), SpFlt( radius )))
  32.       delta_y = SpFix( SpMul( SpSin( SpMul( SpDiv( 3.14159265, 180.0 ),
  33.                               SpFlt( degrees ))), SpFlt( radius )))
  34.  
  35.       pos_x:= pos_x + delta_x
  36.       pos_y:= pos_y + delta_y
  37.  
  38.     ENDPROC
  39.  
  40. Now for the problem, this does not work.  The numbers that I get do not come
  41. out right (not even close).  What am I doing wrong.  Can anyone help me or
  42. possible give me a routine that will do the same thing?
  43.  
  44. NOTE:  I am loading the library correclty and pos_x and pos_y are defined
  45. as globals in the beginning of the program.
  46.  
  47. Thank you in advance.
  48.  
  49. George Beasley...
  50.  
  51. ----------------------------------------------------------------------------
  52.  
  53. MODULE 'WiZkId'
  54. PROC main()
  55.   wizkid.inetaddress:='Politikill@cup.portal.com'
  56.   wizkid.realname:='Jeffrey J Peden ]['
  57. ENDPROC
  58.  
  59.  
  60. *-- GammaTag Version 2.8 --*
  61. *-- What this country needs is a good five-cent nickel.